{% extends 'web/base.html' %}
{% block base_title %} 钻石列表 {% endblock %}
<!--{% block manifest %}appcache/zuanshi.appcache{% endblock %}-->
{% block base_run %}zuanshi{% endblock %}
{% block base_body %}
{% verbatim %}
<div class="open_down scroll all_bg" id="zuanshi" style="overflow-y: auto">
    <div v-if="loading"></div>
    <div v-else class="load_fix">
        <div class="zuan_center" style="background:none;">
            <div class="ui active centered inline loader red" style="top: 50%;transform: scale(.6)"></div>
        </div>
    </div>

    <div class="news_table" v-for="zuan in zuanAll">
        <div class="news_row">
            <div class="news_img1 news_td">
                <div>
                    <img :src="'http://www.zgtxcj.com/'+ zuan.d_image" alt="">
                </div>
            </div>
            <div style="top:0.1rem" class="news_content news_td">
                <p class="con_name">{{ zuan.d_name }}专享</p>
                <p style="color:#d80000">{{ zuan.d_editprice }}元/{{ zuan.d_edition }}个月</p>
                <p v-html="zuan.d_content"></p>
            </div>
            <div class="news_btns news_td">
                <!--<a :href="'/xz/login/?phone='+phone+'&pass='+pass+'&redir=tijiao'">-->
                    <button @click="toTijiao()" onclick="window.localStorage.setItem('did',$(this).attr('did'))" :did="zuan.d_id">{{ zuan.d_introduce }}</button>
                <!--</a>-->
            </div>
        </div>
    </div>
</div>
{% endverbatim %}
{% endblock %}

{% block base_script %}
    var zuanshi = new Vue({
        el:'#zuanshi',
        data:{
            myUrl:'http://api.zgtxcj.com/txcjapi/',
            zuanAll:[],
            loading: false,
            phone: localStorage.getItem('phone'),
            pass: localStorage.getItem('pass'),
        },
        methods:{
            zuan:function(){
                var self=this;
                self.phone=localStorage.getItem('phone');
                self.pass=localStorage.getItem('pass');
                reqwest({
                    url:self.myUrl+'indiamonds/?tag=diamonds',
                    // url:'http://192.168.0.154:4000/txcjapi/indiamonds/?tag=diamonds',
                    method:'get',
                    type:'json',
                    success:function(data){
                        for( var o in data){
                            if(data[o]['d_state']==2){
                                if(data[o]['d_cate']==2){
                                    self.zuanAll.push(data[o]);
                                }
                            }
                        }
                        for(var p in self.zuanAll){
                            self.zuanAll[p]['d_content']=self.zuanAll[p]['d_content'].replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&lt;/g,'<').split('</p>')[0];
                            if(self.zuanAll[p]['d_image'].indexOf('|')!=-1){
                                self.zuanAll[p]['d_image']=self.zuanAll[p]['d_image'].split('|')[0]
                            }
                        }
                        self.loading= true;
                    }
                })
            },
            toTijiao:function(){
                var self = this;
                var puanIos = navigator.userAgent;
                //var isAndroid = puanIos.indexOf('Android') > -1 || puanIos.indexOf('Adr') > -1; //android终端
                var isiOS = !!puanIos.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                if (isiOS) {
                    alert('IOS暂不支持开通钻石服务')
                } else{
                    window.location.href='http://xz.zgtxcj.com/xz/login/?phone='+self.phone+'&pass='+self.pass+'&redir=tijiao';
                }
            },
            run:function () {
                this.zuan();
            }
        },
    })
{% endblock %}
